/*************************************************************************
  Crytek Source File.
  Copyright (C), Crytek Studios, 2001-2012.
 -------------------------------------------------------------------------
  $Id$
  $DateTime$
  Description: 
  
 -------------------------------------------------------------------------
  History:
*************************************************************************/
#ifndef __DELAYEDPLANEBREAK_H__
#define __DELAYEDPLANEBREAK_H__

#if _MSC_VER > 1000
# pragma once
#endif

#include "IIndexedMesh.h"
#include "IPhysics.h"
#include "IDeferredCollisionEvent.h"
#include "IEntitySystem.h"
#include "IBreakableManager.h"

class CDelayedPlaneBreak : public IDeferredPhysicsEvent
{
public:
	enum EStatus
	{
		NONE,
		STARTED,
		DONE,
	};

	CDelayedPlaneBreak() { m_status=NONE; m_threadTaskInfo.m_pThread=0; m_count=0; m_bMeshPrepOnly=false; }
	CDelayedPlaneBreak(const CDelayedPlaneBreak &src) { memcpy(this,&src,sizeof(src)); }
	CDelayedPlaneBreak& operator=(const CDelayedPlaneBreak &src) { memcpy(this,&src,sizeof(src)); return *this; }

	virtual void Start() {}
	virtual int Result(EventPhys*) { return 0; }
	virtual void Sync() {}
	virtual bool HasFinished() { return true; }
	virtual DeferredEventType GetType() const { return PhysCallBack_OnCollision; }
	virtual EventPhys* PhysicsEvent() { return &m_epc; }

	virtual void OnUpdate();
	virtual void Stop() {}
	virtual SThreadTaskInfo* GetTaskInfo() { return &m_threadTaskInfo; }

	volatile int m_status;
	SExtractMeshIslandIn m_islandIn;
	SExtractMeshIslandOut m_islandOut;
	int m_iBreakEvent;
	int m_idx;
	int m_count;

	bool m_bMeshPrepOnly;

	EventPhysCollision m_epc;
	SThreadTaskInfo m_threadTaskInfo;	
};

#endif //__DELAYEDPLANEBREAK_H__